#include <iostream>
#include<list>

#include"list.h"

using namespace std;

void test_list1()
{
	MyList::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	//MyList::list<int>::iterator it = lt.begin();
	auto it = lt.begin();

	while (it != lt.end())
	{
		cout << (*it) << " ";
		++it;
	}
	cout << endl;

}

void test_const(const MyList::list<int> lt)
{
	auto it = lt.begin();
	while (it != lt.end())
	{
		cout << (*it) << " ";
		++it;
	}
	cout << endl;
}


void test_list2()
{
	MyList::list<int> lt;

	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	test_const(lt);
	//MyList::list<int>::iterator it = lt.begin();
	auto it = lt.begin();

	while (it != lt.end())
	{
		cout << (*it) << " ";
		++it;
	}
	cout << endl;
}

void test_list3()
{

	MyList::list<int> lt;

	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);
	
	lt.insert(lt.begin()++, 4);
	lt.insert(lt.begin(), 5);
	lt.erase(lt.begin());
	lt.erase(lt.begin());
	lt.erase(lt.begin());
	lt.erase(lt.begin());
	lt.erase(lt.begin());
	lt.erase(lt.begin());


	//MyList::list<int>::iterator it = lt.begin();
	auto it = lt.begin();

	while (it != lt.end())
	{
		cout << (*it) << " ";
		++it;
	}
	cout << endl;
}

void test_list4()
{
	MyList::list<int> lt;

	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);
	lt.pop_back();
	lt.push_back(4);
	lt.pop_front();
	lt.push_front(1);


	auto it = lt.begin();

	while (it != lt.end())
	{
		cout << (*it) << " ";
		++it;
	}
	cout << endl;
	cout << lt.size() << endl;
}


void test_list5()
{
	MyList::list<int> ltcopy(10, 1);
	MyList::list<int> lt(ltcopy.begin(),ltcopy.end());

	auto it = lt.begin();

	while (it != lt.end())
	{
		cout << (*it) << " ";
		++it;
	}
	cout << endl;
	cout << lt.size() << endl;

}


int main()
{
	test_list5();

	return 0;
}
